#include<stdio.h>

int abs(int x) {
    return x < 0 ? -x : x;
}

int min(int a, int b) {
    return a < b ? a : b;
}

int max(int a, int b) {
    return a > b ? a : b;
}

int main() {
    int T; scanf("%d", &T);
    while(T--) {
        int xa, ya, xb, yb, xf, yf;
        scanf("%d%d%d%d%d%d", &xa, &ya, &xb, &yb, &xf, &yf);
        if((xa - xb != 0) && (ya - yb != 0)) printf("%d\n", abs(xa-xb)+abs(ya-yb));
        else {
            if(xa == xb && xb == xf && min(yb, ya) < yf && max(yb, ya) > yf) printf("%d\n", abs(yb-ya)+2);
            else if(ya == yb && yb == yf && min(xb, xa) < xf && max(xb, xa) > xf) printf("%d\n", abs(xb-xa)+2);
            else printf("%d\n", abs(xb-xa)+abs(yb-ya));
        }        
    }
}